babl: add babl_space_get
authorØyvind Kolås <pippin@gimp.org>
Mon, 9 Jul 2018 20:58:55 +0000 (22:58 +0200)
committerØyvind Kolås <pippin@gimp.org>
Mon, 9 Jul 2018 20:58:58 +0000 (22:58 +0200)
An accessor for getting back out the chromaticities of whitepoint and primaries
as well as trcs.

babl/babl-space.c
babl/babl-space.h
babl/babl.h
export-symbols

index 6df39da43fd8042fdff3ea21b24a43b34ca0c241..6e8774d27e0c4047ac95b0ae2a1e0481391042b5 100644 (file)
@@ -1021,6 +1021,34 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
   return NULL;
 }
 
+
+void babl_space_get (const Babl *babl,
+                     double *xw, double *yw,
+                     double *xr, double *yr,
+                     double *xg, double *yg,
+                     double *xb, double *yb,
+                     const Babl **red_trc,
+                     const Babl **green_trc,
+                     const Babl **blue_trc)
+{
+  const BablSpace *space = &babl->space;
+  /* XXX: note: for spaces set by matrix should be possible to derive
+                the chromaticities of r,g,b and thus even then keep this
+                is canonical data
+   */
+  if(xw)*xw = space->xw;
+  if(yw)*yw = space->yw;
+  if(xr)*xr = space->xr;
+  if(yr)*yr = space->yr;
+  if(xg)*xg = space->xg;
+  if(yg)*yg = space->yg;
+  if(xb)*xb = space->xb;
+  if(yb)*yb = space->yb;
+  if(red_trc)*red_trc = space->trc[0];
+  if(green_trc)*green_trc = space->trc[1];
+  if(blue_trc)*blue_trc = space->trc[2];
+}
+
 /* Trademarks:
  *
  * International Color Consortium is a registered trademarks of the.
index 6aeefb69aa2bf395773012d9b03cf25acdbde653..488fcd002dee195bbf5042b5360216bcec99758f 100644 (file)
@@ -64,6 +64,7 @@ typedef struct
 
 } BablSpace;
 
+
 static inline void babl_space_to_xyzf (const Babl *space, const float *rgb, float *xyz)
 {
   BablSpace *space_ = (void*)space;
index f6ba782723bcf85bdb38440241bf4f0fd3d9a264..23786e5968bfcfccfa6dc16da3df4b86e89d2990 100644 (file)
@@ -507,6 +507,22 @@ char *babl_space_to_icc (const Babl  *space,
                          BablICCFlags flags,
                          int         *icc_length);
 
+/* babl_space_get:
+ *
+ * query thechromaticities of white point and primaries as well as trcs
+ * used for r g a nd b, all arguments mights be NULL.
+ */
+
+void babl_space_get (const Babl *space,
+                     double *xw, double *yw,
+                     double *xr, double *yr,
+                     double *xg, double *yg,
+                     double *xb, double *yb,
+                     const Babl **red_trc,
+                     const Babl **green_trc,
+                     const Babl **blue_trc);
+
+
 #ifdef __cplusplus
 }
 #endif
index 28c18513da9b696e4cd83f6d1a03a6500cac79c1..f9674f7e6253e4c50d28b5524974ff3ad15c6263 100644 (file)
@@ -43,6 +43,7 @@ babl_space
 babl_space_from_xyz
 babl_space_to_icc
 babl_chromaticities_make_space
+babl_space_get
 babl_space_get_rgbtoxyz
 babl_space_to_xyz
 babl_ticks